// with polyfills
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import * as Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/'
import { ProLayout, PageContainer } from '@ant-design-vue/pro-layout'
import bootstrap from './core/bootstrap'
import './core/lazy_use' // use lazy load components
import './permission' // permission control  路由守卫
import './utils/filter' // global filter
import registerSvgIcon from './components/IconSvg/icon.js';

import './global.less' // global style
import 'ant-design-vue/dist/antd.less'
import infoBox from '@/utils/infoBox'
import useClipboard from 'vue-clipboard3'
import moment from 'moment'
import { Form } from 'ant-design-vue'
if (window.$vueApp === undefined) {
  window.$vueApp = Vue.createApp(App)
}

window.$vueApp.use(useClipboard, {
  autoSetContainer: true,
  appendToBody: true
}) // 复制插件
window.$vueApp.config.globalProperties.$moment = moment
window.$vueApp.config.globalProperties.$clipboardConfig = useClipboard
// use pro-layout components
window.$vueApp.component('pro-layout', ProLayout)
window.$vueApp.component('page-container', PageContainer)
window.$vueApp.component('page-header-wrapper', PageContainer)
// window.$vueApp.component('form', Form)

/**
 * @description 全局注册权限验证
 */
window.$vueApp.config.globalProperties.$access = (entId) => {
  // eslint-disable-next-line eqeqeq
  return store.state.user.accessList.some((item) => item == entId)
}

window.$vueApp.config.globalProperties.$infoBox = infoBox

window.$vueApp.config.globalProperties.routerAppend = (path, pathToAppend) => {
  return path + (path.endsWith('/') ? '' : '/') + pathToAppend
}
registerSvgIcon(window.$vueApp)
window.$vueApp.use(store)
window.$vueApp.use(router)
window.$vueApp.use(bootstrap)
window.$vueApp.mount('#app')
